home *** CD-ROM | disk | FTP | other *** search
/ Aminet 13 / Aminet 13 - August 1996.iso / Aminet / dev / e / StringNode.lha / stringnode / examples / StringNode_Example4.e < prev    next >
Text File  |  1996-01-08  |  1KB  |  54 lines

  1. /*
  2. ** StringNode Example-4
  3. **
  4. ** add(), search() AND insert() methods.
  5. **
  6. ** (C)Copyright 1995 Fabio Rotondo
  7. **
  8. ** e-mail: fosft@intercom.it
  9. */
  10.  
  11. MODULE 'fabio/StringNode_oo',   -> Our MAGIC MODULE
  12.        'tools/exceptions'
  13.  
  14. PROC main() HANDLE
  15.   DEF n:PTR TO stringnode      -> This is our OBJECT instance
  16.  
  17.   NEW n.stringnode()           -> OBJECT initialization
  18.  
  19.   n.add('Zorro')              -> Here we add some items...
  20.   n.add('Batman')
  21.   n.add('Superman')
  22.   n.add('Gold Drake')
  23.   n.add('Mandrake')
  24.   n.add('MOMMY')
  25.  
  26.   shwall(n)                   -> Here we see them
  27.  
  28.   n.search('bat#?')           -> The search is CASE insensitive AND match the first one ;)
  29.                               -> Note we use STANDARD AmigaDOS match pattern strings!
  30.  
  31.   WriteF('Current:\s\n', n.obj()) -> Here we are!
  32.  
  33.   n.insert('Spiderman')       -> Wow! Another super-hero after Batman!
  34.   shwall(n)
  35.  
  36. EXCEPT DO
  37.   report_exception()
  38.   END n                       -> Remember ALWAYS TO end an OBJECT
  39.   CleanUp(0)
  40. ENDPROC
  41.  
  42. PROC shwall(n:PTR TO stringnode)
  43.   WriteF('------- \d ----------\n', n.numitems())
  44.  
  45.   IF n.first()                      -> Here we go TO the first node item
  46.     REPEAT
  47.       WriteF('Node:\s\n', n.obj()) -> Node STRING...
  48.     UNTIL n.succ() = FALSE          -> LOOP UNTIL the end
  49.   ELSE
  50.     WriteF('No Nodes in LIST...\n')
  51.   ENDIF
  52. ENDPROC
  53.  
  54.